#ifndef IVSMAINWINDOW_H
#define IVSMAINWINDOW_H

#include <QMainWindow>
#include <QTableWidgetItem>
#include <QCloseEvent>
#include "ivsmodel.h"
#include "IVSNamespace.h"

namespace Ui {
    class IVSMainWindow;
}

class IVSMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit IVSMainWindow(IVSModel* _model, QWidget *parent = 0);
    ~IVSMainWindow();

    /* getters */
    IVS::eFunctions getCurrentFunction();
    QString getCurrentVideoSourceName();

    QString getLog();

public slots:
    /* setters slots */
    void appendLog(QString log, QColor color = Qt::black);
    void setupTableFunction();

    /* clear */
    void clearTableFunction();
    void clearComboVideoSource();
    void clearTableVideoSource();

    /* status bar */
    void status(QString textStatus = QString("Ready "));
    void status(QString textStatus, QColor color);
    void clearStatus();

    void updateVideoSource();
    void updateTableFunction();

private slots:
    void setShowLogButton(bool isShowLog);
    void toggleRunButtonText();

    void on_toolButtonAddVideoSource_clicked();
    void tableVideoSourceItemChanged(QTableWidgetItem* );
    void tableFunctionItemChanged(QTableWidgetItem* );
    void setCurrentFuntion();
    void updateROI(bool );

private:
    Ui::IVSMainWindow *ui;
    QStringList functionList;
    IVSModel* ivsModel;
    bool bUpdate;

    /* initialize the view*/
    void initView();
    void initComboFunction();
    void initTableFunction();
    void initComboVideoSource();
    void initTableVideoSource();
    void initComboVerboseLevel();
    void initTextBrowserLog();
    void createTableFunctionHeader(QStringList listRowHeader);

    void updateComboVideoSource();
    void updateTableVideoSource();
    void closeEvent(QCloseEvent *event);

    void setTableFunctionValue(int row, QString text);
signals:
    void clickedPushButtunRun();
    void currentFunction_changed(IVS::eFunctions );

};

#endif // IVSMAINWINDOW_H
